%option noyywrap nodefault yylineno

%{
    #include <stdbool.h>
    #include "predicate.h"
    #include "predicate.tab.h"
%}

%%

":" |
"," |
"=" |
"+" |
"-" |
"*" |
"/" |
"%" |
"(" |
")" { return yytext[0]; }

";" { return EOS; }

"==" { yylval.l = 0; return LOGICAL; }
">" { yylval.l = 1; return LOGICAL; }
"<" { yylval.l = 2; return LOGICAL; }
"!=" { yylval.l = 3; return LOGICAL; }

"print" { return PRINT; }
"def" { return DEF; }
"fin" { return FIN; }
"if" { return IF; }
"else" { return ELSE; }
"fi" { return FI; }

[a-zA-Z][a-zA-Z0-9]* { yylval.vn = malloc(sizeof(struct varname));
    yylval.vn -> name = yytext;
    yylval.vn -> length = strlen(yytext);
    return IDENTIFIER; }
[0-9]+ { yylval.i = atoi(yytext); return INTEGER; }
[ \t]
"\n"
<<EOF>> { yyterminate(); }
. { yyerror("unrecognized character"); }

%%
